home *** CD-ROM | disk | FTP | other *** search
AmigaBASIC Source Code | 1992-03-23 | 21.9 KB | 776 lines | [MSBC/MSBB] |
- ' •••••• MacTour Golf Player ••••••
- ' Version 1.0
-
- ' ©1987 by M. C. Sumner
- ' 23 Anawood Drive
- ' Arnold, MO 63010
-
- 'This program is distributed on a "shareware" basis. If you enjoy the program
- ' ( or make use of part of the code in another program ) a fee of $10 is
- 'requested. This program should not be duplicated for any publication
- 'without the permission of the author. Permission is herein granted for the
- 'free distribution of this program via eletronic means (i.e. bulletin boards).
-
-
- LIBRARY "ToolLib"
- DIM map%(18,26)
- DIM green%(65),Tee%(65),TreeICON%(65),ShrubICON%(65)
- DIM MapRect%(3),msPt%(1),DispRect%(3,28),ViewRect%(3)
- DIM white%(3),Water%(3),Trees%(3),Sand%(3)
- DIM Rough%(3),HiRough%(3),fair%(3),bounds%(3)
- DIM HitRect1%(3),HitRect2%(3),s$(15)
- DIM DirRect%(3),flipRect%(3),BallRect%(3)
- DIM MaxDist%(16),loft%(16)
- DIM deltax%(27),deltay%(27)
- DIM HoleScore%(18)
-
- ' The following lines define the patterns used to show terrain types
- white%(0)=0:white%(1)=0:white%(2)=0:white%(3)=0
- Sand%(0)=2048:Sand%(1)=16386:Sand%(2)=4096:Sand%(3)=320
- fair%(0)=-21931:fair%(1)=-21931:fair%(2)=-21931:fair%(3)=-21931
- Rough%(0)=-21761:Rough%(1)=-21761:Rough%(2)=-21761:Rough%(3)=-21761
- HiRough%(0)=-69:HiRough%(1)=-18:HiRough%(2)=-69:HiRough%(3)=-18
- bounds%(0)=-1:bounds%(1)=-1:bounds%(2)=-1:bounds%(3)=-1
- Water%(0)=68:Water%(1)=-21999:Water%(2)=68:Water%(3)=-21999
- Trees%(0)=60:Trees%(1)=27262:Trees%(2)=31358:Trees%(3)=15360
- Shrubs%(0)=8306:Shrubs%(1)=28704:Shrubs%(2)=1038:Shrubs%(3)=19972
-
- 'Load patterns into arrays
- FOR a%=0 TO 3:curPatn%(a%)=Bound%(a%):NEXT a%
-
- 'Load Tree,Shrub,Green, and Tee Icons into arrays
- RESTORE IconData
- FOR a=0 TO 17:READ green%(a):NEXT a
- FOR a=0 TO 17:READ Tee%(a):NEXT a
- FOR a=0 TO 65:READ TreeICON%(a):NEXT a
- FOR a=0 TO 65:READ ShrubICON%(a):NEXT a
-
- 'read in club data
- RESTORE ClubData
- FOR a%=1 TO 15 : READ MaxDist%(a%) : NEXT a%
- FOR a%=1 TO 15 : READ loft%(a%) : NEXT a%
-
- 'Set up menus
- MENU 1,0,1,"Game"
- MENU 1,1,1,"New Game"
- MENU 1,2,1,"Open Game..."
- MENU 1,3,0,"Save Game As..."
- MENU 1,4,0,"-"
- MENU 1,5,1,"Quit"
- MENU 3,0,1,"Skill"
- MENU 3,1,2,"Begineer"
- MENU 3,2,1,"Moderate"
- MENU 3,3,1,"Pro"
- MENU 4,0,0,""
- MENU 5,0,0,""
-
- 'About Window (pops up at program start up)
- d%=0:b%=0:ms%=0:PtIn%=0:skill%=1
- WINDOW 1,"",(40,90)-(450,255),2
- CALL <0x0b,0x530d010>(24)
- LOCATE 1,9
- PRINT "MacTour Golf"
- CALL <0x09,0x530d010>(9)
- LOCATE 3,31:PRINT "Version 1.00"
- LOCATE 13,13:PRINT "This is a shareware product, see program listing for details."
- CALL <0x0a,0x530d010>(12)
- CALL <0x20,0x530d010>(165,50):PRINT "By M.C. Sumner"
- CALL <0x3c,0x530d010>(80,125):PRINT "Select 'New Game' or 'Open Game' to begin."
- LINE (10,60)-(400,60)
- LINE (10,62)-(400,64),33,bf
- LINE (10,66)-(400,70),33,bf
- LINE (10,72)-(400,78),33,bf
- LINE (10,80)-(400,88),33,bf
- LINE (10,90)-(400,106),33,bf
- FOR a=1 TO 3
- PUT (a*32-22,28)-(a*32+9,59),TreeICON%(0)
- PUT (a*32+275,28)-(a*32+306,59),TreeICON%(0)
- NEXT a
- Hole%=1
- MainLoop:
- m%=MENU(0):i%=MENU(1)
- IF m%=1 AND i%=1 THEN GOSUB NewGame
- IF m%=1 AND i%=2 THEN GOSUB OpenGame
- IF m%=1 AND i%=5 THEN MENU RESET:END
- IF m%=3 THEN GOSUB SetSkill
- GOTO MainLoop
-
- 'Open course file to begin new game
- NewGame:
- WINDOW CLOSE 1
- Course$=FILES$(1,"MTGC")
- IF LEN(Course$)<1 THEN MENU 1,0,1:RETURN
- OPEN Course$ AS #1 LEN=472
- FIELD #1,1 AS GreenX$,1 AS GreenY$,1 AS TeeX$, 1 AS TeeY$,468 AS HoleMap$
- GOSUB DrawPlayField
- GOSUB GetHole
- Terrain%=1
- GOTO Playhole
-
- 'Open game file to restore old game
- OpenGame:
- WINDOW CLOSE 1
- Game$=FILES$(1,"MTGG")
- IF LEN(Game$)<1 THEN MENU 1,0,1:RETURN
- OPEN Game$ FOR INPUT AS #2
- INPUT #2,Hole%
- FOR i%=1 TO Hole%-1
- INPUT #2,HoleScore%(i%)
- NEXT i%
- INPUT #2,Course$
- CLOSE #2
- OPEN Course$ AS #1 LEN=472
- FIELD #1,1 AS GreenX$,1 AS GreenY$,1 AS TeeX$, 1 AS TeeY$,468 AS HoleMap$
- GOSUB DrawPlayField
- GOSUB GetHole
- GOSUB Playhole
- RETURN
-
-
- SaveGame:
- IF Hole%=1 THEN BEEP:BEEP:RETURN
- Game$=FILES$(0,"Save game as:")
- IF LEN(Game$)>0 THEN
- OPEN Game$ FOR OUTPUT AS #2
- PRINT #2,Hole%
- FOR i%=1 TO Hole%-1
- PRINT #2,HoleScore%(i%)
- NEXT i%
- PRINT #2,Course$
- CLOSE #2
- NAME Game$ AS Game$,"MTGG"
- END IF
- GOSUB DrawPlayField
- OldView%=0
- GOSUB GetHole
- GOSUB DrawView
- RETURN
-
- 'Most action orginates from this routine: direction setting, hitting, etc.
- Playhole:
- CALL <0x13,0x530d010>(VARPTR(flipRect%(0)))
- flip%=NOT flip%
- ms%=MOUSE(0)
- m%=MENU(0)
- i%=MENU(1)
- d%=<0x43,0x530d010>(0):b%=<0x43,0x07>(1)
- IF d%=1 AND b%=1 THEN GOSUB HitBall
- ScrollText s!,scr%(0),s$(0),top%,15,linenum%,4
- IF m%=3 THEN GOSUB SetSkill
- IF m%=1 AND i%=3 THEN GOSUB SaveGame
- IF m%=1 AND i%=5 THEN
- WINDOW CLOSE 1
- MENU RESET
- END
- END IF
- IF ms%=1 THEN
- GetMouse msPt%(0)
- PtInRect msPt%(0),scr%(0),in%
- IF in% THEN GOSUB ChooseClub
- PtInRect msPt%(0),DirRect%(0),in%
- IF in% THEN GOSUB SetAim
- END IF
- GOTO Playhole
- RETURN
-
- 'actually whack that sucker
- HitBall:
- Stroke%=Stroke%+1
- SetRect HitRect2%(0),20,120,36,120
- d%=0 : b%=0 : hit%=0
- WHILE hit%<100 AND d%<>1
- d%=<0x43,0x530d010>(0)
- b%=<0x43,0x530d010>(1)
- hit%=hit%+1
- LINE (20,120-hit%)-(36,120),33,bf
- IF d%=1 AND b%<>1 THEN d%=0
- WEND
- SetRect HitRect2%(0),20,120-hit%,36,120-hit%
- sink%=120-hit% : d%=0 : b%=0
- IF hit%>20 THEN
- WHILE sink%<120 AND d%<>1
- d%=<0x43,0x530d010>(0)
- b%=<0x43,0x530d010>(1)
- sink%=sink%+1
- SetRect HitRect2%(0),20,120-hit%,36,sink%
- CALL <0x1f,0x530d010>(VARPTR(HitRect2%(0)),VARPTR(fair%(0)))
- IF d%=1 AND b%<>1 THEN d%=0
- WEND
- END IF
- IF hit%<21 THEN
- sink%=100
- WHILE d%<>1
- d%=<0x43,0x530d010>(0)
- WEND
- END IF
- sink%=100-sink%
- SOUND 110,0.5,200
- a%=1
- Terrain%=ASC(MID$(Hole$,(x%-1)*26+y%,1))
- GOSUB FillDisplayRect
- IF NOT flip% THEN CALL <0x1e,0x530d010>(VARPTR(flipRect%(0)))
- 'calculate landing spot
- 'first adjust for lie
- IF Terrain%=1 THEN lie=1 : IF Terrain%=2 THEN lie=0.9 : IF Terrain%=3 THEN lie=0.8
- IF Terrain%=4 AND loft%(club%)< 5 THEN lie=0.5 :ELSE IF Terrain%=4 AND loft%(club%)> 4 THEN lie=0.75
- IF Terrain%=7 AND loft%(club%)>4 THEN lie=0.5 :ELSE IF Terrain%=7 AND loft%(club%)< 5 THEN lie=0.9
- rAim=3.14/180*(Aim%+(sink%*skill%*2))
- nx%=BallX%+((MaxDist%(club%)*(hit%/100)*lie)*SIN(rAim)/4)
- ny%=BallY%-((MaxDist%(club%)*(hit%/100)*lie)*COS(rAim)/4)
- IF nx%<352 THEN nx%=354 :ELSE IF nx% >508 THEN nx%=504
- IF ny%<8 THEN ny%=10 :ELSE IF ny%>216 THEN ny%=214
- IF (ny%<>BallY%) THEN sy%=(ny%-BallY%)/ABS((ny%-BallY%))
- IF (nx%<>BallX%) THEN sx%=(nx%-BallX%)/ABS((nx%-BallX%))
- tx%=BallX% : ty%=BallY%
- nm%=ABS(ny%-ty%)+ABS(tx%-nx%)
- mm%=nm%/2 : cm%=0 : alt%=0
- WHILE (ty% <> ny%) OR (tx% <> nx%)
- IF cm%<mm%+1 THEN cm%=cm%+1 : alt%=alt%+loft%(club%)
- IF cm%>mm% THEN alt%=alt%-loft%(club%)
- CALL <0x13,0x530d010>(VARPTR(flipRect%(0)))
- IF (tx% <> nx%) THEN tx%=tx%+sx%
- IF (ty% <> ny%) THEN ty%=ty%+sy%
- SetRect flipRect%(0),tx%-2,ty%-2,tx%+2,ty%+2
- x%=INT((tx%-352)/8)
- y%=INT((ty%-2)/8)
- Terrain%=ASC(MID$(Hole$,(x%-1)*26+y%,1))
- IF Terrain%=6 THEN
- IF alt%>10 AND alt%<45 THEN
- 'Hit a Tree!
- SOUND 255,0.55,250
- CALL <0x13,0x530d010>(VARPTR(flipRect%(0)))
- rAim=3.14/180*(RND*360)
- nx%=tx%+(tx%-nx%)*SIN(rAim)/4
- ny%=ty%-(ty%-ny%)*COS(rAim)/4
- IF (ny%<>ty%) THEN sy%=(ny%-ty%)/ABS((ny%-ty%))
- IF (nx%<>tx%) THEN sx%=(nx%-tx%)/ABS((nx%-tx%))
- WHILE (nx%<>tx%) OR (ny%<>ty%)
- CALL <0x13,0x530d010>(VARPTR(flipRect%(0)))
- IF (tx% <> nx%) THEN tx%=tx%+sx%
- IF (ty% <> ny%) THEN ty%=ty%+sy%
- SetRect flipRect%(0),tx%-2,ty%-2,tx%+2,ty%+2
- CALL <0x13,0x530d010>(VARPTR(flipRect%(0)))
- WEND
- END IF
- END IF
- CALL <0x13,0x530d010>(VARPTR(flipRect%(0)))
- WEND
- GOSUB CheckValidLanding
- BallX%=nx% : BallY%=ny%
- OldView%=0
- CALL <0x13,0x530d010>(VARPTR(flipRect%(0)))
- SetRect flipRect%(0),BallX%-2,BallY%-2,BallX%+2,BallY%+2
- CALL <0x13,0x530d010>(VARPTR(flipRect%(0)))
- x%=INT((BallX%-352)/8)-1
- y%=INT((BallY%-2)/8)
- IF x%=gdx1% AND y%=gdy% THEN GOSUB PutOut
- IF x%=gdx2% AND y%=gdy% THEN GOSUB PutOut
- IF x%=gdx1% AND y%=gdy%+1 THEN GOSUB PutOut
- IF x%=gdx2% AND y%=gdy%+1 THEN GOSUB PutOut
- GOSUB DrawView
- GOSUB ShowDistance
- CALL <0x1f,0x530d010>(VARPTR(HitRect1%(0)),VARPTR(white%(0)))
- flip%=-1
- RETURN
-
- CheckValidLanding:
- invalid%=0
- tx%=INT((nx%-352)/8)-1
- ty%=INT((ny%-2)/8)
- Terrain%=ASC(MID$(Hole$,(tx%-1)*26+ty%,1))
- IF Terrain%=8 OR Terrain%=5 THEN invalid%=-1
- IF Terrain%=8 THEN invalid$="The ball has gone out of bounds."+CHR$(13)+CHR$(13)
- IF Terrain%=5 THEN invalid$="The ball has landed in water."+CHR$(13)+CHR$(13)
- invalid$=invalid$+"A one stroke penalty will be assessed." +CHR$(13)+CHR$(13)+"You must hit over."
- IF invalid% THEN
- WINDOW 2,"",(140,50)-(320,190),-2
- <0x40,0x530d010> 1,1,"OK",(40,110)-(140,130),1
- SetRect tbRect%(0),10,10,170,100
- TextBox invalid$,tbRect%(0),1
- d%=0 : b%=0
- WHILE d%<> 1
- d%=<0x43,0x530d010>(0)
- b%=<0x43,0x530d010>(1)
- WEND
- WINDOW CLOSE 2
- nx%=BallX% : ny%=BallY%
- Stroke%=Stroke%+1
- END IF
- RETURN
-
- 'print stroke and distance
- ShowDistance:
- CALL <0x0a,0x530d010>(12)
- LOCATE 13,16 : PRINT SPACE$(56) : LOCATE 13,16
- PRINT "Hole:";Hole%;
- PRINT "Stroke:";Stroke%;
- dx=GreenRect%(1)+7-BallX%:dy=GreenRect%(0)+7-BallY%
- dis%=SQR(dx^2+dy^2)*4
- PRINT "Dist.:";dis%;"Yds"
- CALL <0x09,0x530d010>(9)
- RETURN
-
- ChooseClub:
- linenum%=top%+(msPt%(0)-scr%(0))\19
- 'calculate line of array clicked on
- top%=0
- ScrollText s!,scr%(0),s$(0),top%,15,linenum%,4
- 'linenum% is highlighted with this redraw
- club%=linenum%
- WHILE MOUSE(0)<>0:WEND
- 'wait for mouse up
- RETURN
-
- 'change direction of shot & show appropriate view
- SetAim:
- angle%=Aim%
- rAim=3.14/180*Aim%
- LINE(63,173)-(63+(35*SIN(rAim)),173-(35*COS(rAim))),30
- PtToAngle DirRect%(0),msPt%(0),Aim%
- rAim=3.14/180*Aim%
- LINE(63,173)-(63+(35*SIN(rAim)),173-(35*COS(rAim))),33
- WHILE MOUSE(0)<>0:WEND
- 'wait for mouse up
- LOCATE 18,3:PRINT " "
- LOCATE 18,3:PRINT STR$(Aim%)+"°"
- IF NOT OnGreen% THEN GOSUB DrawView
- RETURN
-
- DrawPlayField:
- WINDOW 1,,(0,20)-(512,342),4
- SetRect MapRect%(0),364,14,499,213
- SetRect DispRect%(0,1),130,156,330,180
- SetRect DispRect%(0,2),130,140,196,156
- SetRect DispRect%(0,3),196,140,263,156
- SetRect DispRect%(0,4),263,140,330,156
- SetRect DispRect%(0,5),130,128,170,140
- SetRect DispRect%(0,6),170,128,210,140
- SetRect DispRect%(0,7),210,128,250,140
- SetRect DispRect%(0,8),250,128,290,140
- SetRect DispRect%(0,9),290,128,330,140
- SetRect DispRect%(0,10),130,120,158,128
- SetRect DispRect%(0,11),158,120,187,128
- SetRect DispRect%(0,12),187,120,216,128
- SetRect DispRect%(0,13),216,120,245,128
- SetRect DispRect%(0,14),245,120,274,128
- SetRect DispRect%(0,15),274,120,305,128
- SetRect DispRect%(0,16),305,120,330,128
- SetRect DispRect%(0,17),130,116,152,120
- SetRect DispRect%(0,18),152,116,174,120
- SetRect DispRect%(0,19),174,116,196,120
- SetRect DispRect%(0,20),196,116,218,120
- SetRect DispRect%(0,21),218,116,240,120
- SetRect DispRect%(0,22),230,116,262,120
- SetRect DispRect%(0,23),252,116,284,120
- SetRect DispRect%(0,24),274,116,306,120
- SetRect DispRect%(0,25),306,116,330,120
- LINE(0,0)-(512,342),33,bf
- LINE(9,9)-(351,218),30,bf
- LINE(359,9)-(504,218),30,bf
- LINE(9,224)-(504,321),30,bf
- LINE(128,18)-(332,182),33,b
- CALL <0x0a,0x530d010>(9)
- LOCATE 20,3:PRINT "HOLE :"
- LOCATE 21,3:PRINT "PAR :"
- LOCATE 22,3:PRINT "YARDS:"
- LOCATE 23,3:PRINT"SCORE:"
- totpar%=0 : totdis%=0
- FOR a% = 1 TO 18
- LOCATE 20,a%*4+7:PRINT a%
- GET #1,a%
- GreenX%=ASC(GreenX$)*8+360:GreenY%=ASC(GreenY$)*8+2
- TeeX%=ASC(TeeX$)*8+360:TeeY%=ASC(TeeY$)*8+2
- SetRect GreenRect%(0),GreenX%,GreenY%,GreenX%+15,GreenY%+15
- SetRect TeeRect%(0),TeeX%,TeeY%,TeeX%+15,TeeY%+15
- dx=GreenRect%(1)-TeeRect%(1):dy=GreenRect%(0)-TeeRect%(0)
- dis%=SQR(dx^2+dy^2)*4
- par%=3
- IF dis%>250 THEN par%=4
- IF dis%>500 THEN par%=5
- LOCATE 21,a%*4+7:PRINT par%
- LOCATE 22,a%*4+7:PRINT dis%
- totdis%=totdis%+dis% : totpar%=totpar%+par%
- NEXT a%
- LOCATE 24,20 : PRINT "Par for Course:";totpar%,"Course DIstance:";totdis%
- LINE (1,276)-(511,276)
- FOR a%=1 TO Hole% -1
- LOCATE 24,a%*4+7:PRINT HoleScore%(a%)
- NEXT a%
- LINE(19,19)-(36,121),33,b
- SetRect HitRect1%(0),20,20,36,120
- SetRect HitRect2%(0),20,120,36,120
- LINE(15,40)-(40,40)
- LINE(15,100)-(40,100)
- CALL <0x1f,0x530d010>(VARPTR(HitRect1%(0)),VARPTR(white%(0)))
- <0x40,0x530d010> 1,1,"Hit",(50,100)-(110,120),1
- linenum%=0 : top%=0 : s!=0 : in%=0
- SetRect scr%(0),50,20,95,90
- SetRect bar%(0),94,20,110,90
- <0x532210e,0x530d010> VARPTR(scr%(0))
- NewScroll s!,bar%(0),1,1,10,1
- RESTORE ClubNames
- FOR n=0 TO 14: READ n$:s$(n)=n$:NEXT n
- ScrollText s!,scr%(0),s$(0),top%,15,1,4
- club%=1
- SetRect DirRect%(0),25,135,101,211
- CALL <0x0b,0x530d010>(2,2)
- CALL <0x13,0x530d010>(VARPTR(DirRect%(0)))
- CALL <0x0b,0x530d010>(1,1)
- LINE(63,173)-(63,137)
- Aim%=0
- LOCATE 18,3:PRINT " "
- LOCATE 18,3:PRINT STR$(Aim%)+"°"
- MENU 1,0,1
- MENU 1,1,0
- MENU 1,2,0
- MENU 1,3,1
- RETURN
-
- GetHole:
- GET #1,Hole%
- GreenX%=ASC(GreenX$)*8+360:GreenY%=ASC(GreenY$)*8+2
- TeeX%=ASC(TeeX$)*8+360:TeeY%=ASC(TeeY$)*8+2
- Hole$=HoleMap$
- SetRect GreenRect%(0),GreenX%,GreenY%,GreenX%+15,GreenY%+15
- SetRect TeeRect%(0),TeeX%,TeeY%,TeeX%+15,TeeY%+15
- BallY%=TeeRect%(0)+7:BallX%=TeeRect%(1)+7
- dx=GreenRect%(1)-TeeRect%(1):dy=GreenRect%(0)-TeeRect%(0)
- dis%=SQR(dx^2+dy^2)*4
- gdx1%=ASC(GreenX$) : gdx2%=ASC(GreenX$)+1 : gdy%=ASC(GreenY$)
- LINE(130,20)-(330,180),30,bf
- LINE(140,30)-(320,100),33,b
- LINE(220,100)-(240,170),33,b
- LINE(135,170)-(325,170)
- CALL <0x0a,0x530d010>(12)
- CALL <0x09,0x530d010>(1)
- LOCATE 4,18 : PRINT "Loading Hole:";Hole%
- LOCATE 5,18:PRINT "Length:";dis%;"Yards"
- CALL <0x09,0x530d010>(0)
- CALL <0x09,0x530d010>(9)
- GOSUB DrawHole
- SetRect flipRect%(0),TeeRect%(1)+5,TeeRect%(0)+5,TeeRect%(1)+11,TeeRect%(0)+11
- CALL <0x13,0x530d010>(VARPTR(flipRect%(0)))
- Stroke%=1:flip%=-1
- GOSUB ShowDistance
- OnGreen%=0
- RETURN
-
- DrawHole:
- CALL <0x1f,0x530d010>(VARPTR(MapRect%(0)),VARPTR(white%(0)))
- FOR x%=1 TO 18
- FOR y%=1 TO 26
- SetRect UtilRect%(0),x%*8+352,y%*8+2,x%*8+360,y%*8+10
- Terrain$=MID$(Hole$,(x%-1)*26+y%,1)
- Terrain%=ASC(Terrain$)
- IF Terrain%=1 THEN CALL <0x2a,0x530d010>(VARPTR(UtilRect%(0)),VARPTR(fair%(0)))
- IF Terrain%=2 THEN CALL <0x2a,0x530d010>(VARPTR(UtilRect%(0)),VARPTR(Rough%(0)))
- IF Terrain%=3 THEN CALL <0x2a,0x530d010>(VARPTR(UtilRect%(0)),VARPTR(HiRough%(0)))
- IF Terrain%=4 THEN CALL <0x2a,0x530d010>(VARPTR(UtilRect%(0)),VARPTR(Sand%(0)))
- IF Terrain%=5 THEN CALL <0x2a,0x530d010>(VARPTR(UtilRect%(0)),VARPTR(Water%(0)))
- IF Terrain%=6 THEN CALL <0x2a,0x530d010>(VARPTR(UtilRect%(0)),VARPTR(Trees%(0)))
- IF Terrain%=7 THEN CALL <0x2a,0x530d010>(VARPTR(UtilRect%(0)),VARPTR(Shrubs%(0)))
- IF Terrain%=8 THEN CALL <0x2a,0x530d010>(VARPTR(UtilRect%(0)),VARPTR(bounds%(0)))
- NEXT y%
- NEXT x%
- PUT (GreenX%,GreenY%)-(GreenX%+15,GreenY%+15),green%(0),PSET
- PUT (TeeX%,TeeY%)-(TeeX%+15,TeeY%+15),Tee%(0),PSET
- OldView%=0
- GOSUB DrawView
- RETURN
-
- DrawView:
- IF Aim%<46 OR Aim%>315 THEN NewView%=1
- IF Aim%<136 AND Aim%>45 THEN NewView%=2
- IF Aim%<226 AND Aim%>135 THEN NewView%=3
- IF Aim%<316 AND Aim%>225 THEN NewView%=4
- IF NewView% = OldView% THEN RETURN
- OldView% = NewView%
- IF NewView%=1 THEN RESTORE NorthView
- IF NewView%=2 THEN RESTORE EastView
- IF NewView%=3 THEN RESTORE SouthView
- IF NewView%=4 THEN RESTORE WestView
- SetRect ViewRect%(0),130,20,330,180
- ClipRect ViewRect%(0)
- LINE(130,20)-(330,180),30,bf
- x%=INT((BallX%-352)/8)-1
- y%=INT((BallY%-2)/8)
- FOR a%=1 TO 25 : READ deltax%(a%),deltay%(a%) : NEXT a%
- FOR a%=25 TO 1 STEP -1
- dx%=deltax%(a%)+x% : dy%=deltay%(a%)+y%
- IF dx%>0 AND dx%<18 THEN
- IF dy%>0 AND dy%<27 THEN
- Terrain%=ASC(MID$(Hole$,(dx%)*26+dy%,1))
- END IF
- END IF
- IF dx%<1 OR dx%>18 THEN Terrain%=8
- IF dy%<1 OR dy%>26 THEN Terrain%=8
- GOSUB FillDisplayRect
- NEXT a%
- FOR a%=1 TO 25
- dx%=deltax%(a%)+x% : dy%=deltay%(a%)+y%
- IF dx%=gdx1% AND dy%=gdy% THEN
- w%=(DispRect%(3,a%)-DispRect%(1,a%))*2
- h%=(DispRect%(2,a%)-DispRect%(0,a%))
- IF NewView%<>3 THEN SetRect UtilRect%(0),DispRect%(1,a%),DispRect%(0,a%),DispRect%(3,a%)+w%,DispRect%(2,a%)+h%
- IF NewView%=3 THEN SetRect UtilRect%(0),DispRect%(1,a%)-w%,DispRect%(0,a%),DispRect%(3,a%),DispRect%(2,a%)+h%
- CALL <0x1f,0x530d010>(VARPTR(UtilRect%(0)),VARPTR(white%(0)))
- CALL <0x13,0x530d010>(VARPTR(UtilRect%(0)))
- GOSUB DrawFlag
- dx%=99 : a%=25
- END IF
- IF dx%=gdx2% AND dy%=gdy% THEN
- w%=(DispRect%(3,a%)-DispRect%(1,a%))*2
- h%=(DispRect%(2,a%)-DispRect%(0,a%))
- IF NewView%=3 THEN SetRect UtilRect%(0),DispRect%(1,a%),DispRect%(0,a%),DispRect%(3,a%)+w%,DispRect%(2,a%)+h%
- IF NewView%<>3 THEN SetRect UtilRect%(0),DispRect%(1,a%)-w%,DispRect%(0,a%),DispRect%(3,a%),DispRect%(2,a%)+h%
- CALL <0x1f,0x530d010>(VARPTR(UtilRect%(0)),VARPTR(white%(0)))
- CALL <0x13,0x530d010>(VARPTR(UtilRect%(0)))
- GOSUB DrawFlag
- dx%=99 : a%=25
- END IF
- NEXT a%
- READ View$
- CALL <0x0a,0x530d010>(12)
- LOCATE 3,25:PRINT View$
- CALL <0x09,0x530d010>(9)
- SetRect BallRect%(0),225,165,235,175
- CALL <0x1f,0x530d010>(VARPTR(BallRect%(0)),VARPTR(white%(0)))
- CALL <0x13,0x530d010>(VARPTR(BallRect%(0)))
- SetRect ViewRect%(0),0,0,512,342
- ClipRect ViewRect%(0)
- RETURN
-
- DrawFlag:
- midx%=(UtilRect%(1)+UtilRect%(3))/2
- midy%=(UtilRect%(0)+UtilRect%(2))/2
- h%=UtilRect%(2)-UtilRect%(0)
- LINE(midx%,midy%)-(midx%,midy%-h%)
- LINE(midx%,midy%-h%)-(midx%-(h%/2),midy%-h%+(h%/4))
- LINE(midx%-(h%/2),midy%-h%+(h%/4))-(midx%,midy%-h%+(h%/4))
- RETURN
-
- FillDisplayRect:
- IF Terrain%=1 THEN CALL <0x2f,0x530d010>(VARPTR(DispRect%(0,a%)),VARPTR(fair%(0)))
- IF Terrain%=2 THEN CALL <0x2f,0x530d010>(VARPTR(DispRect%(0,a%)),VARPTR(Rough%(0)))
- IF Terrain%=3 THEN CALL <0x2f,0x530d010>(VARPTR(DispRect%(0,a%)),VARPTR(HiRough%(0)))
- IF Terrain%=4 THEN CALL <0x2f,0x530d010>(VARPTR(DispRect%(0,a%)),VARPTR(Sand%(0)))
- IF Terrain%=5 THEN CALL <0x2f,0x530d010>(VARPTR(DispRect%(0,a%)),VARPTR(Water%(0)))
- IF Terrain%=6 THEN
- CALL <0x24,0x530d010>(VARPTR(DispRect%(0,a%)),VARPTR(HiRough%(0)))
- Diff%=(DispRect%(2,a%)-DispRect%(0,a%))*6
- PUT (DispRect%(1,a%),DispRect%(2,a%)-Diff%)-(DispRect%(3,a%),DispRect%(2,a%)),TreeICON%(0),OR
- END IF
- IF Terrain%=7 THEN
- CALL <0x24,0x530d010>(VARPTR(DispRect%(0,a%)),VARPTR(Rough%(0)))
- Diff%=(DispRect%(2,a%)-DispRect%(0,a%))*3
- PUT (DispRect%(1,a%),DispRect%(2,a%)-Diff%)-(DispRect%(3,a%),DispRect%(2,a%)),ShrubICON%(0),OR
- END IF
- IF Terrain%=8 THEN CALL <0x2f,0x530d010>(VARPTR(DispRect%(0,a%)),VARPTR(bounds%(0)))
- RETURN
-
- PutOut:
- dx=GreenRect%(1)+7-BallX%:dy=GreenRect%(0)+7-BallY%
- dis%=SQR(dx^2+dy^2)*12
- OnGreen%=-1
- LINE(130,20)-(330,180),30,bf
- SetRect UtilRect%(0),130,20,330,180
- SetRect CupRect%(0),225,95,235,105
- CALL <0x1f,0x530d010>(VARPTR(UtilRect%(0)),VARPTR(fair%(0)))
- CALL <0x1f,0x530d010>(VARPTR(UtilRect%(0)),VARPTR(white%(0)))
- CALL <0x13,0x530d010>(VARPTR(UtilRect%(0)))
- CALL <0x1f,0x530d010>(VARPTR(CupRect%(0)),VARPTR(bounds%(0)))
- InsetRect CutRect%(0),2,2
- BallX%=228 : BallY%=100+(dis%/2)
- SetRect UtilRect%(0),BallX%,BallY%,BallX%+4,BallY%+4
- GOSUB ShowPutDistance
- CALL <0x13,0x530d010>(VARPTR(UtilRect%(0)))
- MENU 1,0,0 : MENU 3,0,0
- CALL <0x1f,0x530d010>(VARPTR(HitRect1%(0)),VARPTR(white%(0)))
- PutOut%=0
- WHILE NOT PutOut%
- ms%=MOUSE(0)
- d%=<0x43,0x530d010>(0):b%=<0x43,0x07>(1)
- IF d%=1 AND b%=1 THEN GOSUB HitPut
- IF ms%=1 THEN
- GetMouse msPt%(0)
- PtInRect msPt%(0),DirRect%(0),in%
- IF in% THEN GOSUB SetAim
- END IF
- WEND
- Hole%=Hole%+1
- IF Hole%=19 THEN EndRound
- GOSUB GetHole
- Terrain%=1
- MENU 1,0,1 : MENU 3,0,1
- RETURN
-
- HitPut:
- Stroke%=Stroke%+1
- SetRect HitRect2%(0),20,120,36,120
- d%=0 : b%=0 : hit%=0
- WHILE hit%<100 AND d%<>1
- d%=<0x43,0x530d010>(0)
- b%=<0x43,0x530d010>(1)
- hit%=hit%+1
- LINE (20,120-hit%)-(36,120),33,bf
- IF d%=1 AND b%<>1 THEN d%=0
- WEND
- SetRect HitRect2%(0),20,120-hit%,36,120-hit%
- sink%=120-hit% : d%=0 : b%=0
- IF hit%>20 THEN
- WHILE sink%<120 AND d%<>1
- d%=<0x43,0x530d010>(0)
- b%=<0x43,0x530d010>(1)
- sink%=sink%+1
- SetRect HitRect2%(0),20,120-hit%,36,sink%
- CALL <0x1f,0x530d010>(VARPTR(HitRect2%(0)),VARPTR(fair%(0)))
- IF d%=1 AND b%<>1 THEN d%=0
- WEND
- END IF
- IF hit%<21 THEN
- sink%=100
- WHILE d%<>1
- d%=<0x43,0x530d010>(0)
- WEND
- END IF
- sink%=100-sink%
- SOUND 710,0.5,200
- Terrain%=ASC(MID$(Hole$,(x%-1)*26+y%,1))
- rAim=3.14/180*(Aim%+(sink%*skill%*2))
- nx%=BallX%+(hit%*SIN(rAim))
- ny%=BallY%-(hit%*COS(rAim))
- IF ny%< 21 THEN ny%=21 :ELSE IF ny%>179 THEN ny%=179
- IF nx%<131 THEN nx%=131 :ELSE IF nx%>329 THEN nx%=329
- IF (ny%<>BallY%) THEN sy%=(ny%-BallY%)/ABS((ny%-BallY%))
- IF (nx%<>BallX%) THEN sx%=(nx%-BallX%)/ABS((nx%-BallX%))
- tx%=BallX% : ty%=BallY%
- WHILE (ty% <> ny%) OR (tx% <> nx%)
- CALL <0x13,0x530d010>(VARPTR(UtilRect%(0)))
- IF (tx% <> nx%) THEN tx%=tx%+sx%
- IF (ty% <> ny%) THEN ty%=ty%+sy%
- SetRect UtilRect%(0),tx%-2,ty%-2,tx%+2,ty%+2
- CALL <0x13,0x530d010>(VARPTR(UtilRect%(0)))
- WEND
- BallX%=nx% : BallY%=ny%
- CALL <0x1f,0x530d010>(VARPTR(HitRect1%(0)),VARPTR(white%(0)))
- msPt%(0)=ny% : msPt%(1)=nx%
- PtInRect msPt%(0),CupRect%(0),in%
- IF in% THEN
- PutOut%=-1
- CALL <0x13,0x530d010>(VARPTR(UtilRect%(0)))
- SOUND 210,0.5,200 : SOUND 150,0.3,150 : SOUND 110,0.15,100
- LOCATE 23,Hole%*4+7 : PRINT Stroke%-1
- HoleScore%(Hole%)=Stroke%-1
- END IF
- IF NOT PutOut% THEN ShowPutDistance
- RETURN
-
- ShowPutDistance:
- CALL <0x0a,0x530d010>(12)
- LOCATE 13,16 : PRINT SPACE$(56) : LOCATE 13,16
- PRINT "Hole:";Hole%;
- PRINT "Stroke:";Stroke%;
- dx=230-BallX%:dy=100-BallY%
- dis%=SQR(dx^2+dy^2)/3
- PRINT "Dist.:";dis%;"ft"
- CALL <0x09,0x530d010>(9)
- RETURN
-
- SetSkill:
- FOR a%=1 TO 3: MENU 3,a%,1:NEXT a%
- MENU 3,i%,2
- skill%=a%
- RETURN
-
- EndRound:
- CALL <0x0a,0x530d010>(12)
- CALL <0x09,0x530d010>(1)
- LOCATE 20,3
- i%=0
- FOR a%=1 TO 18 : i%=i%+HoleScore%(a%) : NEXT a%
- PRINT "Total Score:";i%
- <0x40,0x530d010> 2,1,"Off to the 19th Hole!",(350,300)-(500,320),1
- d%=0 : b%=0
- WHILE d%<>1 OR b%<>2
- d%=<0x43,0x530d010>(0)
- b%=<0x43,0x530d010>(1)
- WEND
- WINDOW CLOSE 1
- END
-
- IconData:
- ' Data for ICON: Green
- DATA 16,16,-20486,20485,-24350,16625
- DATA-32543,-32639,-32639,-32319,-32095
- DATA-32223,-32319,-32767,-32766,16389
- DATA-24566,24565
- ' Data for ICON: tee
- DATA 16,16,-21846, 21845,-16386,24581
- DATA-24570,24581,-24570,27701,-21450
- DATA 24581,-24570,24581,-24570,32765
- DATA-21846,21845
- ' Data for ICON: Tree
- DATA 32 , 32 , 0 , 0 , 1 , 0 , 3 ,-32768 , 2 ,-16384
- DATA 7 ,-24576 , 5 ,-8192 , 15 , 20480 , 31 ,-4096 , 31 ,-2048
- DATA 55 ,-1024 , 63 ,-512 , 127 ,-256 , 255 ,-3072 , 1022 ,-512
- DATA 379 ,-128 , 255 ,-64 , 1023 ,-160 , 1535 ,-512 , 511 ,-512
- DATA 1791 ,-768 , 2559 ,-128 , 1015 ,-576 , 2047 ,-2368 , 3327 ,-416
- DATA 4606 ,-24800 , 1911 ,-30848 , 8071 ,-32576 , 12294 ,-32672 , 7 ,-32752
- DATA 7 ,-32768 , 7 ,-32768 , 15 ,-16384
- ' Data for ICON: Shrub
- DATA 32 , 32 , 0 , 0 , 0 , 0 , 0 , 0 , 15 , 0
- DATA 63 ,-2048 , 247 ,-16896 , 447 ,-128 , 1019 ,-64 , 2047 ,-2144
- DATA 4031 ,-16 , 7166 ,-16 , 8191 ,-8 , 15855 ,-8328 , 32767 ,-4
- DATA 32767 ,-1044 , 24574 ,-4 , 32511 ,-2 , 31711 ,-8194 , 16383 ,-66
- DATA 16381 ,-522 , 6143 ,-8196 , 8127 ,-4 , 3839 ,-16392 , 2030 ,-528
- DATA 1023 ,-64 , 255 ,-16512 , 3 ,-4096 , 1 ,-24576 , 1 ,-24576
- DATA 1 ,-8192 , 1 , 24576 , 3 ,-4096
-
- ClubNames:
- DATA "Driver","2 Wood","3 Wood","4 Wood"
- DATA "1 Iron","2 Iron","3 Iron","4 Iron","5 Iron","6 Iron","7 Iron","8 Iron","9 Iron"
- DATA "P. Wedge","S. Wedge"
-
- ClubData:
- 'Maximum distance data
- DATA 300,250,220,200
- DATA 205,195,185,175,165,155,145,135,125
- DATA 100,80
- 'Loft data
- DATA 1,2,4,5
- DATA 1,2,3,4,5,6,7,8,9
- DATA 10,11
-
- NorthView:
- DATA 0,0
- DATA -1,-1,0,-1,1,-1
- DATA -2,-2,-1,-2,0,-2,1,-2,2,-2
- DATA -3,-3,-2,-3,-1,-3,0,-3,1,-3,2,-3,3,-3
- DATA -4,-4,-3,-4,-2,-4,-1,-4,0,-4,1,-4,2,-4,3,-4,4,-4
- DATA "North View"
-
- EastView:
- DATA 0,0
- DATA 1,-1,1,0,1,1
- DATA 2,-2,2,-1,2,0,2,1,2,2
- DATA 3,-3,3,-2,3,-1,3,0,3,1,3,2,3,3
- DATA 4,-4,4,-3,4,-2,4,-1,4,0,4,1,4,2,4,3,4,4
- DATA "East View"
-
- SouthView:
- DATA 0,0
- DATA 1,1,0,1,-1,1
- DATA 2,2,1,2,0,2,-1,2,-2,2
- DATA 3,3,2,3,1,3,0,3,-1,3,-2,3,-3,3
- DATA 4,4,3,4,2,4,1,4,0,4,-1,4,-2,4,-3,4,-4,4
- DATA "South View"
-
- WestView:
- DATA 0,0
- DATA -1,1,-1,0,-1,-1
- DATA -2,2,-2,1,-2,0,-2,-1,-2,-2
- DATA -3,3,-3,2,-3,1,-3,0,-3,-1,-3,-2,-3,-3
- DATA -4,4,-4,3,-4,2,-4,1,-4,0,-4,-1,-4,-2,-4,-3,-4,-4
- DATA "West View"
-
-